Skip to content

Make iOS keyboard observation and actions explicit - #4681

Merged
thymikee merged 9 commits into
mainfrom
t3/reevaluate-ios-keyboard-handling
Nov 18, 2026
Merged

thymikee merged 9 commits into
mainfrom
t3/reevaluate-ios-keyboard-handling

Conversation

@thymikee

@thymikee thymikee commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Make keyboard commands predictable across iOS and iPadOS apps and languages. 41 files.

Affected command Before After
keyboard status (get) Could count off-screen keys as visible. Reads software keys across the display, including below placed windows, and reports recognized localized Return labels.
keyboard enter (return) Probed English labels and could focus the only text field. Sends one Return to the focused input.
keyboard dismiss, Maestro hideKeyboard Could tap an unrelated Done button. Refuses while software keys are visible. When available, use an explicit dismissal control.
gesture pan Could reject drags into the keyboard. One-finger timed pans can cross the keyboard. Maestro swipes avoid it.

iPad examples with Polish Search open.

  • agent-device keyboard status --json → visible: true, returnKey: "search", returnKeyLabel: "szukaj".
  • agent-device keyboard dismiss --json → UNSUPPORTED_OPERATION, reason keyboard_dismiss_unavailable, dispatched: "no".
  • agent-device snapshot -i → Hide Keyboard at @e67 in this capture. agent-device press @e67 hid the keys.

Validation

  • Base 972b5a5a23 tapped adjacent Done. At 066c183d88, iPad CLI tests confirmed refusal, explicit dismissal, and drag dismissal. Device evidence
  • The single-display regression failed on fa4f796caa. Both variants passed on db7acdea4d, along with affected validation and all 18 hosted checks. The single-display test runs in XCTest Nightly’s iPhone full-suite lane.
  • On 8ffee4df54, the docs-only affected gate and all 18 hosted checks passed. Sentinel approved.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.40 MB 6.38 MB -16.5 kB
Package (unpacked) 6.40 MB 6.38 MB -16.5 kB
Package (download) 1.94 MB 1.94 MB -3.8 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 35.9 ms 33.8 ms -2.1 ms
CLI --help 75.9 ms 70.8 ms -5.1 ms

@thymikee

Copy link
Copy Markdown
Member Author

At 20c1d99 the code looks sound, but I can't call it ready: the new iPad paths and the daemon-routed dismiss refusal have no live run. One check is still queued and the other 16 pass. Nothing in the diff overlaps a non-passing job.

The cited evidence covers iPhone 16 / iOS 26.2 runner XCTests and two replays. The new iPad branches have no device run: accessory-only means hidden (RunnerKeyboardStatus.swift:39), the return-key rule on iPad key rows, and the recovery path the help now prescribes in place of the deleted iPad hide-key dismissal (press the Hide Keyboard key by ref). The keyboard dismiss refusal through the daemon is also unshown, and no run is cited for the edited ios-simulator-e2e live-runner step. This is a device-facing change to dispatch and observation, and the iPad behavior removed from #4644 is now replaced by guidance no run has exercised. Please run this on an iPad simulator through the CLI and daemon. First, focus a text field with the software keyboard up and run keyboard status --json; expect visible:true and a returnKey. Second, run keyboard dismiss --json; expect UNSUPPORTED_OPERATION with details.reason keyboard_dismiss_unavailable, details.dispatched no, and no app change. Third, run snapshot -i, then press on the Hide Keyboard key ref; expect no tap_keyboard_occludes_target refusal, then keyboard status showing visible:false. Fourth, with the hardware keyboard connected so only the accessory bar shows, keyboard status should show visible:false. Alternatively, cite a run of test/integration/ios-simulator-e2e live-runner assertFormInput at this head for the iPhone daemon route.

Not blocking, take or leave: the iOS dismiss mechanism field now has no producer (Swift DataPayload.keyboardDismissMechanism is never assigned, yet the interactor, daemon message branch in keyboard-runtime.ts, session journal enum and both contract fields still carry it), so deleting it end to end would reduce the iOS 'mechanism' result to the hidden no-op acknowledgement; keyboardSpace in RunnerKeyboardStatus.swift:54 adds a second quarter-turn detector where SnapshotGeometrySpace.space already decides the same question for keyboardBandFact, so one shared helper would serve both; and the comments at device-input-state.ts:157 and :42-46 still say iOS refuses 'a keyboard that stays up' after a safe mechanism, when iOS now refuses a visible keyboard before dispatch and Android after its escape keyevents.

Behavior on real iPad key planes (split, floating, Stage Manager) rests on the code only. The docs say Limrun iOS sessions route keyboard dismiss and status through this runner build, so the same refusal would apply there. Once the iPad and daemon run is posted, the remaining cleanups are small.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 3 new findings on 20c1d99. The verdict and the full list are in the summary comment.

@thymikee
thymikee force-pushed the t3/reevaluate-ios-keyboard-handling branch from 20c1d99 to 066c183 Compare November 18, 2026 11:28
@thymikee

Copy link
Copy Markdown
Member Author

Verified on iPad A16 / iPadOS 26.2 through the built CLI and daemon at 066c183d88.

Check Observed
Status with software keyboard visible: true, returnKey: "search", returnKeyLabel: "szukaj"
Automatic dismiss UNSUPPORTED_OPERATION, reason: "keyboard_dismiss_unavailable", dispatched: "no". Return, accessory, and app-action counters stayed at zero.
Explicit Hide Keyboard snapshot -i exposed the key at @e67. Pressing it succeeded and status reported visible: false.
Hardware keyboard with accessory bar The 44-point accessory remained onscreen and status reported visible: false.
Interactive drag A timed one-finger pan hid the keyboard. The native viewport test also confirmed the default read still clips above the keys.

The released dismiss-mechanism field remains readable for older runners. The rotation path uses the shared coordinate transform. Its detached keyboard snapshot lacks the full-window ancestry that the capture-side detector uses. The Android refusal comments now describe the different dispatch outcomes.

@thymikee
thymikee marked this pull request as ready for review November 18, 2026 11:29
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 066c183. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At 066c183 the keyboard avoidance is back as the default, and only the daemon one-finger pan crosses the keyboard. The label-only Search case is now documented and tested. Your live device report at 066c183 covers the route.

The Coverage check failed, but its log (job) stops about 2.5 minutes into vitest run --coverage, with no failing test, no summary and no threshold line. That looks like the runner ended the process rather than a test failure. Please re-run it. If it fails again with a real assertion, especially in the touched interactions.test.ts or the daemon gesture code, fix that before merge.

Not blocking, take or leave: (1) The rule that picks the keyboard-inclusive viewport at gesture-runtime.ts#L125 has no daemon test, so setting it to true or undefined keeps every TS test green. One test that binds the plan tier with a fake gestureViewport should show the flag for a one-finger pan and not for a fling, swipe or two-finger pan. (2) Maestro swipe steps become a pan without pointerCount (daemon-runtime-public-operation.ts#L345), so coordinate swipes without a paired viewport now cross the keyboard too. Either say so in the docs or key the rule on the public gesture pan request. (3) The runner reuses action to carry include-keyboard (runner-contract.ts#L138); a dedicated optional boolean read only for gestureViewport would be clearer.

Could the runner's gestureViewport return the frame plus the keyboard band top that frameAvoidingKeyboard already computes? The shared planner already branches on intent and pointerCount in buildPanPlan, so it could pick the bound for a one-finger pan. That would remove the boolean threaded through GestureViewportInput, Interactor.gestureViewport, selectGestureFrame, bindGestureTier and the overloaded action. It would also put the rule next to the intent it depends on. The runner response would need an optional keyboard-band field, and the planner would need to accept a keyboard bound. If that is too large now, the current shape is fine once (1) and (3) are in.

On the open inline threads: the one on lit-panel viewport reads does not apply, because keyboardStatus does not call elementSearchRoots and an unreadable read fails closed to OBSERVATION_UNAVAILABLE as documented. The thread on pressKeyboardReturn failing is resolved as intended behavior. The threads on identifier-only status and default keyboard avoidance are fixed at this head, so they can be resolved.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

At 9a24f44 the findings from the earlier review (#4681 (comment)) are fixed. Not blocking, and you can take or leave these: the new includesKeyboard runner field has no row in the shared request fixture (see the failing check below), and the Maestro guidance in https://github.com/callstack/agent-device/blob/9a24f44/website/docs/docs/run-maestro-flows.md#L69 and packages/maestro/src/internal/support-matrix.ts could say the suggested drag must stay above the keyboard, because a drag onto the keyboard is refused in Maestro.

The Apple smoke job is red because of this change. testEveryRunnerRequestFieldHasAProductionRequest fails at https://github.com/callstack/agent-device/blob/9a24f44/packages/platform-apple/runner/RunnerTests/RunnerTests%2BModelsTests.swift#L175 with ["includesKeyboard"] != [], and the Apple aggregate check fails with it. Every stored runner request field needs a production request row, so add a gestureViewport({ includesKeyboard: true }) row in index-runner-requests.test.ts and regenerate contracts/fixtures/runner-requests.json. That is the one thing to fix before merge. The Android smoke job fails in the emulator fixture check Android Home should replace fixture pixels. The diff does not touch that route, and the PR body links the same failure on base, so it looks unrelated.

The renamed wire field matches between the TS sender and the Swift key by inspection, but nothing on a device shows a pan crossing the keyboard at this head. The earlier live report covered the same route with the old field name. There are no conflicts.

The open inline threads on #4681 (comment) (unreadable keyboard read fails closed, as documented), #4681 (comment) (return key unavailable with unknown dispatch is intentional and documented), #4681 (comment) (identifier-only status was fixed earlier) and #4681 (comment) (keyboard avoidance is the default, now narrowed further) do not apply at this commit, so you can resolve them.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The earlier findings on 9a24f44 are fixed, and I found one remaining defect at fa4f796. All 18 checks pass at fa4f796, including Smoke Tests (macos), which exercises the updated runner-request fixture. The latest delta only touches test fixtures and docs. There are no conflicts.

The production keyboard status reader in RunnerKeyboardStatus.swift passes the snapshot viewport, which resolves the app window. The classifier intersects the system keyboard frame with that window and reports hidden when they do not overlap. The placed-iPad fixture in CoordinateSpaceTests.swift has the app window ending at y=889 and the keyboard starting at y=925. That keyboard has 282 points visible on the display and zero inside the app window. With a software keyboard below a placed iPad window, status can report visible: false, and keyboard dismiss then returns a successful no-op while the keyboard stays up. Visibility and Return-key filtering should use verified display or panel bounds in the keyboard frame's coordinate space. They should return OBSERVATION_UNAVAILABLE when those bounds cannot be established. Please add a test for a visible keyboard below a placed app window.

Could the native observation in RunnerTests+Keyboard.swift take the display or panel bounds from the runner's existing geometry authority and pass them to RunnerKeyboardStatus.observed, so keyboard visibility does not depend on the app window used for snapshot presentation?

The earlier automated thread on elsewhere-read search roots does not apply and can be resolved, because keyboardStatus does not call elementSearchRoots and an unreadable read fails closed to OBSERVATION_UNAVAILABLE: #4681 (comment)

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The earlier findings from fa4f796 are fixed in b804cbf, but the placed-window case still has no test that would catch a regression. All 18 checks pass, and Smoke Tests (ios) exercises the changed keyboardStatus sole-display route live through smoke:form-input. There are no conflicts. Before merge, please add the runner test below.

The daemon sends litPanel only for multi-panel (foldable) devices: resolveRunnerRequestLitPanel returns undefined unless the read is multi-panel. So the case the earlier review raised, a software keyboard below a placed iPad window (Windowed Apps or Stage Manager), takes the else branch at RunnerTests+Keyboard.swift:179-181. testKeyboardCommandsUseTheDisplayBelowAPlacedWindow sends litPanel displayId 3, so it only drives the requestLitPanel branch. The classifier tests pass display sizes directly, and the iPhone smoke covers only a full-screen sole display, where window and display coincide. If the else branch went back to the app-window viewport, every test would stay green. The rule the code must satisfy: on every route that reaches keyboardStatus, visibility is measured against the display that hosts the app, never the app window. Please add the same placed-window case without litPanel: probe the app window at 224,207 386x682, seed mainOwned.soleDisplayPortraitSize = 834x1210 (or stub RunnerSoleScreenSize), and assert keyboardStatus is visible with returnKey done and keyboardDismiss refused. Parameterizing the existing test over both branches also works.

Not blocking, and fine to take or leave: the lit-panel-else-sole-screen selection at RunnerTests+Keyboard.swift:175 repeats edgeTouchDisplayPortraitSize (RunnerTests+ScreenEdgeGesture.swift:81-86), books the lit-panel window only to read a size that requestLitPanel already carries, and reads orientation from two sources, so one owner such as hostDisplayFrame(app:) used by keyboardStatus and the edge-touch path would remove the duplication.

@thymikee

Copy link
Copy Markdown
Member Author

Addressed the missing single-display placed-window case in db7acdea4d. The runner test sends keyboardStatus and keyboardDismiss without litPanel, with a placed 386 × 682 app window at (224, 207) and a measured 834 × 1210 display.

  • On fa4f796caa, the test reported the software keyboard as hidden, omitted Return metadata, and allowed a dismiss no-op.
  • On db7acdea4d, both placed-window variants passed on the iPad A16 simulator running iPadOS 26.2. Status reported visible with Return kind done and label OK, and dismiss returned KEYBOARD_DISMISS_UNAVAILABLE.

The local affected gate and hosted checks are running.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The sole-display placed-window regression you added now covers the earlier finding, and the keyboard geometry code did not change. One docs problem remains at db7acde.

The capability note at capabilities.md#L128 says the Apple runner reports unknown when the key's wording names no known action. The runner classifies the accessibility identifier instead (RunnerKeyboardStatus.swift#L45-L53). A key labeled szukaj with identifier Search returns search, as the test at RunnerTests+KeyboardReturnKeyTests.swift:18-29 pins. A reader could expect unknown for a localized Return label and write the wrong status assertion. Please say that the recognized accessibility identifier gives the action, the localized wording gives the label, and the action is unknown only when the runner cannot identify it.

The open inline thread on the keyboardStatus read block (discussion) does not apply: it is resolved, and returning nil when the state cannot be measured is the intended contract, so the author can resolve it.

All 18 checks pass at db7acde. The new test skips when the host has more than one screen, so please name the CI lane that runs it in the PR body. After the docs fix, this is ready to merge.

@thymikee

Copy link
Copy Markdown
Member Author

Updated the capability note in cb72733a95. A recognized accessibility identifier gives the Return action, the localized wording gives the label, and an unidentified action reports unknown. The example pairs Search with szukaj.

The PR body now names XCTest Nightly’s iPhone full-suite lane for the single-display regression. The source-derived test selection confirms that lane includes it. I verified that the keyboard-status thread remains resolved. Docs link and prose checks passed, and CI is running on the new head. Review

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 8ffee4d

Since the review of db7acde: 1 new · 0 still open · 1 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift:596 🆕 keyboard dismiss never ends editing on tvOS — the Siri Remote Menu press is gone

1 finding below minor hidden (user_settings.min_severity).

1 new finding away from what changed since db7acde not shown. Comment @apex-sentinel-staging review for a full review.

Reviewed with this repository's own Sentinel configuration (894c80ac681c).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 8ffee4d. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

The earlier findings from db7acde (#4681 (comment)) are now fixed in 8ffee4d. This update touches only a docs note and its generator annotation, so it overlaps no device or runner route, and I found no new problems in it.

Could resolveGestureRuntimePlan in packages/contracts/src/platform-runtime-operations.ts own the keyboard-inclusive viewport policy for the existing single-pointer plan tier? That would reuse the contact classification there and let the daemon forward the selected mode. The Apple adapter and Swift runner could keep translating that mode into the native clipping choice.

The remaining check is a review check, not a test job. There are no conflicts. The design question above is the last thing before the label: either move the policy, or reply with why the current split is smaller.

@thymikee

Copy link
Copy Markdown
Member Author

I’d keep the viewport policy in the daemon binding for this PR. resolveGestureRuntimePlan selects the required runtime operation. Its single-pointer plan tier includes timed pans, coordinate flings, and Maestro’s endpoint-hold pans. The viewport exception applies only to timed one-finger pans, so the tier alone does not determine clipping.

Moving the rule would reuse the pointer classification and remove one argument from the daemon binder. It would also add a viewport option to the shared plan type with one consumer, while the daemon would still project it into the same bound viewport request. Keeping the rule at that binding leaves the shared plan interface smaller. The daemon tests cover one- and two-finger pans, a directional fling, a coordinate swipe, and a Maestro endpoint-hold swipe. Daemon binding · Viewport tests · Review

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 18, 2026
@thymikee

Copy link
Copy Markdown
Member Author

Thanks, that answers the design question. The viewport exception applies only to timed one-finger pans, while the plan tier also covers flings and endpoint-hold pans, so the tier alone cannot decide clipping. A shared-plan option with one consumer would grow the shared interface for no gain. Keeping the rule at the daemon binding is the smaller design, and the viewport tests cover each gesture kind. With the docs fix at 8ffee4d and no code findings, this is ready for review.

@thymikee
thymikee merged commit affb94c into main Nov 18, 2026
18 checks passed
@thymikee
thymikee deleted the t3/reevaluate-ios-keyboard-handling branch November 18, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant